<?php
namespace src;
use classlib\input;
use src\logic\Cadmin;
use src\logic\limapi;
use classlib\core as C;
use classlib\core\controller;
use src\logic\lrobots;
class Cim extends controller {
	public function dolimitget() {
		$view  = C\view::inst('json');
		Cadmin::islogin($view);
		//0--禁言用户 1--踢出用户 2---屏蔽用户
		$gagexpire  = limapi::getlimitlen(0);
		$kickexpire = limapi::getlimitlen(1);
		$view->assign_by_ref('gagexpire', $gagexpire);
		$view->assign_by_ref('kickexpire', $kickexpire);
		$view->display();
	}
	
	public function dolimitset() {
		$view  = C\view::inst('json');
		Cadmin::islogin($view);
		$gagexpire  = (int)input::get_post('gagexpire');
		$kickexpire = (int)input::get_post('kickexpire');
		($gagexpire > 0) && limapi::setlimitlen(0, $gagexpire);
		($kickexpire > 0) && limapi::setlimitlen(1, $kickexpire);
		$view->display();
	}
	
	//重置直播间机器人资料信息
	public function robotsreset() {
		$view  = C\view::inst('json');
		Cadmin::islogin($view);
		$ids   = \classlib\validator\auditor::intstr2arr('ids');
		if(empty($ids)) {
			$view->assign_error('1', '请选择要处理的记录');
		}
		foreach ($ids as $sid) {
			$sid = intval($sid);
			if ($sid > 0) {
				limapi::delrobotlist($sid);
				lrobots::reset($sid);
			}
		}
		$view->display();
	}
}